<?php
/*
	代理地区
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['pluginset']=$this->plugin_setting('setting');
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$agent_area=$this->get('agent_area',array('mid'=>$_SESSION['uid']));
	$return['area_total']=1;
	$return['params']=array(
		'page'=>1,
		'area_type'=>0,
	);
	$return['list']=array();
	$return['area_types']=$this->area_types;
	$return['page_setting']=$this->plugin_setting('page');
	set_html('title','我的团队');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('mid'=>$_SESSION['uid']);
	if(isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
	}
	if($_RQ['area_type']){
		$params['area_type']=intval($_RQ['area_type']);
	}
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
	);
	$agent_area=$this->get('agent_area',array('mid'=>$_SESSION['uid']));
	if($agent_area['is_duodai'] && $pindex<=1){
		$duodai=str_array($agent_area['duodai']);
		foreach($duodai as $dv){
			$list[]=array(
				'address'=>$dv
			);
		}
	}else{
		$list=$this->get_list('agent_area',$parameter);
		if(!$list){
			exi('none');
		}
		foreach($list as &$item){
			$item['address']=pdo_getcolumn('core_area',array('code'=>$item['area_code']),'address');
		}
	}
	if(!$list){
		exi('none');
	}
	exi($list);
}
?>